<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="css/mui.min.css">
		<style>
			html,
			body {
				background-color: #efeff4;
			}
			
			.mui-views,
			.mui-view,
			.mui-pages,
			.mui-page,
			.mui-page-content {
				position: absolute;
				left: 0;
				right: 0;
				top: 0;
				bottom: 0;
				width: 100%;
				height: 100%;
				background-color: #efeff4;
			}
			
			.mui-pages {
				top: 46px;
				height: auto;
			}
			
			.mui-scroll-wrapper,
			.mui-scroll {
				background-color: #efeff4;
			}
			
			.mui-page.mui-transitioning {
				-webkit-transition: -webkit-transform 300ms ease;
				transition: transform 300ms ease;
			}
			
			.mui-page-left {
				-webkit-transform: translate3d(0, 0, 0);
				transform: translate3d(0, 0, 0);
			}
			
			.mui-ios .mui-page-left {
				-webkit-transform: translate3d(-20%, 0, 0);
				transform: translate3d(-20%, 0, 0);
			}
			
			.mui-navbar {
				position: fixed;
				right: 0;
				left: 0;
				z-index: 10;
				height: 44px;
				background-color: #f7f7f8;
			}
			
			.mui-navbar .mui-bar {
				position: absolute;
				background: transparent;
				text-align: center;
			}
			
			.mui-android .mui-navbar-inner.mui-navbar-left {
				opacity: 0;
			}
			
			.mui-ios .mui-navbar-left .mui-left,
			.mui-ios .mui-navbar-left .mui-center,
			.mui-ios .mui-navbar-left .mui-right {
				opacity: 0;
			}
			
			.mui-navbar .mui-btn-nav {
				-webkit-transition: none;
				transition: none;
				-webkit-transition-duration: .0s;
				transition-duration: .0s;
			}
			
			.mui-navbar .mui-bar .mui-title {
				display: inline-block;
				width: auto;
			}
			
			.mui-page-shadow {
				position: absolute;
				right: 100%;
				top: 0;
				width: 16px;
				height: 100%;
				z-index: -1;
				content: '';
			}
			
			.mui-page-shadow {
				background: -webkit-linear-gradient(left, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, .01) 50%, rgba(0, 0, 0, .2) 100%);
				background: linear-gradient(to right, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, .01) 50%, rgba(0, 0, 0, .2) 100%);
			}
			
			.mui-navbar-inner.mui-transitioning,
			.mui-navbar-inner .mui-transitioning {
				-webkit-transition: opacity 300ms ease, -webkit-transform 300ms ease;
				transition: opacity 300ms ease, transform 300ms ease;
			}
			
			.mui-page {
				display: none;
			}
			
			.mui-pages .mui-page {
				display: block;
			}
			
			.mui-page .mui-table-view:first-child {
				margin-top: 15px;
			}
			
			.mui-page .mui-table-view:last-child {
				margin-bottom: 30px;
			}
			
			.mui-table-view {
				margin-top: 20px;
			}
			
			.mui-table-view span.mui-pull-right {
				color: #999;
			}
			
			.mui-table-view-divider {
				background-color: #efeff4;
				font-size: 14px;
			}
			
			.mui-table-view-divider:before,
			.mui-table-view-divider:after {
				height: 0;
			}
			
			.head {
				height: 40px;
			}
			
			#head {
				line-height: 40px;
			}
			
			.head-img {
				width: 40px;
				height: 40px;
			}
			
			#head-img1 {
				position: absolute;
				bottom: 10px;
				right: 40px;
				width: 40px;
				height: 40px;
			}
			
			.update {
				font-style: normal;
				color: #999999;
				margin-right: -25px;
				font-size: 15px
			}
			
			.mui-fullscreen {
				position: fixed;
				z-index: 20;
				background-color: #000;
			}
			
			.mui-ios .mui-navbar .mui-bar .mui-title {
				position: static;
			}
			/*问题反馈在setting页面单独的css*/
			
			#feedback .mui-popover {
				position: fixed;
			}
			
			#feedback .mui-table-view:last-child {
				margin-bottom: 0px;
			}
			
			#feedback .mui-table-view:first-child {
				margin-top: 0px;
			}
			/*问题反馈在setting页面单独的css==end*/
			/*我的二维码*/
			
			.own {
				width: 300px;
				margin: 50px auto 0 auto;
				min-height: 250px;
			}
			
			.own div {
				line-height: 40px
			}
			
			#qrcode {
				margin-top: 10px;
				padding: 25px;
			}
			#qrcodeName {
				margin-top: 10px;
				padding: 0px;
			}
		</style>
		<link rel="stylesheet" type="text/css" href="css/feedback.css" />
	</head>

	<body class="mui-fullscreen">
		<!--页面主结构开始-->
		<div id="app" class="mui-views">
			<div class="mui-view">
				<div class="mui-navbar">
				</div>
				<div class="mui-pages">
				</div>
			</div>
		</div>
		<!--页面主结构结束-->
		<!--单页面开始-->
		<div id="setting" class="mui-page">
			<!--页面标题栏开始-->
			<div class="mui-navbar-inner mui-bar mui-bar-nav">

				<h1 class="mui-center mui-title">个人信息</h1>
			</div>
			<!--页面标题栏结束-->
			<!--页面主内容区开始-->
			<div class="mui-page-content">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll">
						<ul class="mui-table-view mui-table-view-chevron">
							<li class="mui-table-view-cell mui-media">
								<a class="mui-navigate-right" href="#look">
									<img class="mui-media-object mui-pull-left head-img" id="head-img" src="images/user-photo.png">
									<div class="mui-media-body">

										<p id="name"></p>
										<p class='mui-ellipsis' id="loginName"></p>
										<p id="job"></p>
									</div>
								</a>
							</li>
						</ul>

						<ul class="mui-table-view mui-table-view-chevron">
							<li class="mui-table-view-cell">
								<a href="#account" class="mui-navigate-right">我的账号</a>
							</li>
						</ul>

						<ul class="mui-table-view mui-table-view-chevron">
							<li class="mui-table-view-cell">
								<a href="#about" class="mui-navigate-right">关于软件 <i id="version" class="mui-pull-right update"></i></a>
							</li>
						</ul>
						<ul class="mui-table-view" style="margin-top: 25px;">
							<li class="mui-table-view-cell" id="out">
								<a style="text-align: center;color: #FF3B30;">
									退出登录
								</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
			<!--页面主内容区结束-->
		</div>
		<!--单页面结束-->
		<!--单页面结束-->
		<div id="account" class="mui-page">
			<div class="mui-navbar-inner mui-bar mui-bar-nav">
				<button type="button" class="mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left">
					<span class="mui-icon mui-icon-left-nav"></span>设置
				</button>
				<h1 class="mui-center mui-title">我的账号</h1>
			</div>
			<div class="mui-page-content">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll">
						<ul class="mui-table-view mui-table-view-chevron">
							<li class="mui-table-view-cell">
								<a id="head" class="mui-navigate-right">头像
									<span class="mui-pull-right head">
									<img class="head-img mui-action-preview" id="head-img1" src="images/user-photo.png"/>
								</span>
								</a>
							</li>
						</ul>
						<ul class="mui-table-view mui-table-view-chevron" id="ulId">
							<li class="mui-table-view-cell" id='X1'>
								<a>姓名<span class="mui-pull-right mui-navigate-right update" id="G1"></span></a>
							</li>
							<li class="mui-table-view-cell" id='X2'>
								<a>年龄<span class="mui-pull-right mui-navigate-right update" id="G2"></span></a>
							</li>
							<li class="mui-table-view-cell" id='X3'>
								<a>性别<span class="mui-pull-right mui-navigate-right update" id="G3"></span></a>
							</li>
							<div class="mui-input-row ">

						</ul>
						<ul class="mui-table-view mui-table-view-chevron" id="ulId">
							<li class="mui-table-view-cell " id='X4'>
								<a>QQ号<span class="mui-pull-right mui-navigate-right update" id="G4"></span></a>
							</li>
							<li class="mui-table-view-cell" id='X5'>
								<a>手机号<span class="mui-pull-right mui-navigate-right update" id="G5"></span></a>
							</li>
							<li class="mui-table-view-cell " id='X6'>
								<a>邮箱地址<span class="mui-pull-right mui-navigate-right update" id="G6"></span></a>
							</li>
							<li class="mui-table-view-cell" id='X7'>
								<a>地址<span class="mui-pull-right mui-navigate-right update " id="G7"></span></a>
							</li>
						</ul>
						</div>
					</div>
				</div>
			</div>

			<!--
        	作者：1014879098@qq.com
        	时间：2017-11-10
        	描述：我的二维码
        -->
			<div id="look" class="mui-page">
				<div class="mui-navbar-inner mui-bar mui-bar-nav">
					<button type="button" class="mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left">
					<span class="mui-icon mui-icon-left-nav"></span>
				</button>
					<h1 class="mui-center mui-title">我的二维码</h1>
				</div>
				<div class="mui-page-content">
					<div class="mui-scroll-wrapper">
						<div class="mui-scroll">
							<div class="mui-content-padded">
								<form class="mui-input-group">
									<div class="own">

										<div id="qrcodeName">&nbsp;&nbsp;&nbsp;姓名：<span id="logoName"></span></div>
										<div id="qrcodeName"</span>&nbsp;&nbsp;&nbsp;职位：<span id="logoJob"></span></div>
										<div id="qrcode"><img id="imgLogo" src="" style="position: absolute; left:140px; top:220px; width: 60px; height: 60px; " /></div>

									</div>
								</form>

							</div>

						</div>
					</div>
				</div>
			</div>

			<div id="about" class="mui-page">
				<div class="mui-navbar-inner mui-bar mui-bar-nav">
					<button type="button" class="mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left">
					<span class="mui-icon mui-icon-left-nav"></span>设置
				</button>
					<h1 class="mui-center mui-title">关于软件</h1>
				</div>
				<div class="mui-page-content">
					<div class="mui-scroll-wrapper">
						<div class="mui-scroll">
							<ul class="mui-table-view">

								<li class="mui-table-view-cell mui-plus-visible">
									<a id="share" class="mui-navigate-right">分享推荐</a>
								</li>
								<li class="mui-table-view-cell">
									<a id="tel" class="mui-navigate-right">客服电话</a>
								</li>
								<li class="mui-table-view-cell">
									<a id="feedback-btn" href="#feedback" class="mui-navigate-right">问题反馈</a>
								</li>
								<li id="check_update" class="mui-table-view-cell mui-plus-visible">
									<a id="update" class="mui-navigate-right">检查更新</a>
								</li>
							</ul>
						</div>
					</div>
				</div>
			</div>

			<div id="feedback" class="mui-page feedback">
				<div class="mui-navbar-inner mui-bar mui-bar-nav">
					<button type="button" class="mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left">
					<span class="mui-icon mui-icon-left-nav"></span>关于软件
				</button>
					<button id="submit" class="mui-btn mui-btn-blue mui-btn-link mui-pull-right" onclick="sendQusetion()">发送</button>
					<h1 class="mui-center mui-title">问题反馈</h1>
				</div>
				<div class="mui-page-content">
					<div class="mui-content-padded">
						<div class="mui-inline">问题和意见</div>
						<a class="mui-pull-right mui-inline" href="#popover">
							意见参考
							<span class="mui-icon mui-icon-arrowdown"></span>
						</a>
						<!--快捷输入具体内容，开发者可自己替换常用语-->
						<div id="popover" class="mui-popover">
							<div class="mui-popover-arrow"></div>
							<div class="mui-scroll-wrapper">
								<div class="mui-scroll">
									<ul class="mui-table-view">
										<!--仅流应用环境下显示-->
										
										<li class="mui-table-view-cell" id="tip1">
											<a id="tipText1" href="#">界面显示错乱</a>
										</li>
										<li class="mui-table-view-cell" id="tip2">
											<a  id="tipText2"href="#">启动缓慢，卡出翔了</a>
										</li>
										<li class="mui-table-view-cell" id="tip3">
											<a id="tipText3" href="#">偶发性崩溃</a>
										</li>
										<li class="mui-table-view-cell" id="tip4">
											<a id="tipText4" href="#">UI无法直视，丑哭了</a>
										</li>
									</ul>
								</div>
							</div>
						</div>
					</div>
					<div class="row mui-input-row">
						<textarea id='questionText' class="mui-input-clear question" placeholder="请详细描述你的问题和意见..."></textarea>
					</div>
					<p>图片(选填,提供问题截图)</p>
					<div id='image-list' class="row image-list">
						<img class="head-img mui-action-preview" id="qusetion-img" src="images/jiahao.jpg" />
					</div>
					<p>QQ/邮箱</p>
					<div class="mui-input-row">
						<input id='line' type="text" class="mui-input-clear contact" placeholder="(选填,方便我们联系你 )" />
					</div>
					<div class="mui-content-padded">
						<div class="mui-inline">应用评分</div>
						<div class="icons mui-inline" style="margin-left: 6px;">
							<i data-index="1" class="mui-icon mui-icon-star"></i>
							<i data-index="2" class="mui-icon mui-icon-star"></i>
							<i data-index="3" class="mui-icon mui-icon-star"></i>
							<i data-index="4" class="mui-icon mui-icon-star"></i>
							<i data-index="5" class="mui-icon mui-icon-star"></i>
						</div>
					</div><br/>
				</div>
			</div>

	</body>
	<script src="js/mui.min.js "></script>
	<script src="js/mui.view.js "></script>
	<script src='js/feedback.js'></script>
	<script src="js/qrcode.js"></script>
	<script>
		mui.init();
		//初始化单页view
		var viewApi = mui('#app').view({
			defaultPage: '#setting'
		});
		//初始化单页的区域滚动
		mui('.mui-scroll-wrapper').scroll();
			
			
		
		
		//变量
		var loginName = localStorage.getItem("loginName");
		var phone = document.getElementById("loginName");
		var updateFile="";//升级文件
		
		
		//数据加载
		
		
		var network = true;
		if(mui.os.plus) {
			mui.plusReady(function() {
				if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
					network = false;
				}
			});
		}
		if(network) {
			//console.log('网络正常,正在发送请求...');

			mui.ajax({
				type: "post",
				url: "http://113.71.26.27:8080/tpl/phone/getPhoneImg",
				async: true,
				data: {
					loginName: loginName
				},
				dataType: "json",
				timeout: 10000,
				crossDomain: true,
				success: function(data) {
					//console.log('响应成功！');
					//console.log(data);

					var SName = data.loginName;

					if(SName == loginName) {
						var photoUrl = data.imgUrl;
						var logo = document.getElementById('head-img');
						var logo2 = document.getElementById('head-img1');
						logo.src = "http://113.71.26.27:8080/tpl/public/uploadImage/peopleLogo/" + photoUrl;
						logo2.src = "http://113.71.26.27:8080/tpl/public/uploadImage/peopleLogo/" + photoUrl;
						var getName = data.name;
						var Name = document.getElementById("name");
						var Name2 = document.getElementById("G1");
						Name.innerHTML = "姓名：" + getName;
						Name2.innerHTML = getName;
						localStorage.setItem("myName",getName);
						var getLoginName = data.loginName;
						var Name3 = document.getElementById("loginName");
						Name3.innerHTML = "账号：" + getLoginName;
						var getJob = data.job;
						if(getJob == null) {
							var job = document.getElementById("job");
							job.innerHTML = "职位：暂无";
							var logoJob = document.getElementById("logoJob");
							logoJob.innerHTML = "职位：暂无";
						} else {
							var job = document.getElementById("job");
							job.innerHTML = "职位：" + getJob;
							var logoJob = document.getElementById("logoJob");
							logoJob.innerHTML = getJob;
						}
						
						//二维码
						var logoName = document.getElementById('logoName');
						logoName.innerHTML = getName;
						var logo3 = document.getElementById('imgLogo');
						logo3.src = "http://113.71.26.27:8080/tpl/public/uploadImage/peopleLogo/" + photoUrl;
						var qrcode = new QRCode('qrcode', {
							text: loginName,
							width: 256,
							height: 256,
							colorDark: '#000000',
							colorLight: '#ffffff',

							correctLevel: QRCode.CorrectLevel.H
						});

						// 使用 API
						//qrcode.clear();
						//qrcode.makeCode("http://127.0.0.1:8020/system2/setting.html");

						var getAge = data.age;
						var age = document.getElementById("G2");
						age.innerHTML = getAge;
						var getSex = data.sex;
						var sex = document.getElementById("G3");
						sex.innerHTML = getSex;

						var getQQ = data.qq;
						var qq = document.getElementById("G4");
						qq.innerHTML = getQQ;
						var getPhone = data.phone;
						var phone2 = document.getElementById("G5");
						phone2.innerHTML = getPhone;
						var getEmail = data.email;
						var email = document.getElementById("G6");
						email.innerHTML = getEmail;
						var getAdress = data.address;
						var adress = document.getElementById("G7");
						if(getAdress==""){
							adress.innerHTML = "请输入...";
							
						}else{
							adress.innerHTML = getAdress;
						}
						
						//设置软件版本号
						var version="";
						var versionText = document.getElementById("version");
						
				        mui.plusReady(function() {
							 plus.runtime.getProperty(plus.runtime.appid,function(inf){
				            version=inf.version;
				            versionText.innerHTML=version;
				        });
						});
					} else {

					}

				},
				error: function(xhr, type, errorThrown) {
					plus.nativeUI.toast(errorThrown);
				}
			});

		} else {
			mui.toast("当前网络不给力，请稍后再试...");
		}

		var view = viewApi.view;
		(function($) {
			//处理view的后退与webview后退
			var oldBack = $.back;
			$.back = function() {
				if(viewApi.canBack()) { //如果view可以后退，则执行view的后退
					viewApi.back();
				} else { //执行webview后退
					oldBack();
				}
			};
			//监听页面切换事件方案1,通过view元素监听所有页面切换事件，目前提供pageBeforeShow|pageShow|pageBeforeBack|pageBack四种事件(before事件为动画开始前触发)
			//第一个参数为事件名称，第二个参数为事件回调，其中e.detail.page为当前页面的html对象
			view.addEventListener('pageBeforeShow', function(e) {
				//				console.log(e.detail.page.id + ' beforeShow');
			});
			view.addEventListener('pageShow', function(e) {
				//				console.log(e.detail.page.id + ' show');
			});
			view.addEventListener('pageBeforeBack', function(e) {
				//				console.log(e.detail.page.id + ' beforeBack');
			});
			view.addEventListener('pageBack', function(e) {
				//				console.log(e.detail.page.id + ' back');
			});
		})(mui);
	</script>

	<script type="text/javascript">
		//选择图片的数据
		var imgData = ""; //头像
		var imgData2 = "";
		var imgData3 = ""; //问题提交
		var imgData4 = "";
		var sendImgData = "";
		var start = 0;
		var loginName = localStorage.getItem("loginName");
		/*点击头像触发*/
		document.getElementById('head').addEventListener('tap', function() {
			if(mui.os.plus) {
				var a = [{
					title: "拍照"
				}, {
					title: "从手机相册选择"
				}];
				plus.nativeUI.actionSheet({
					title: "选择用户头像",
					cancel: "取消",
					buttons: a
				}, function(b) { /*actionSheet 按钮点击事件*/
					switch(b.index) {
						case 0:
							break;
						case 1:
							getImage("changeImg"); /*拍照*/
							break;
						case 2:
							galleryImg("changeImg"); /*打开相册*/
							break;
						default:
							break;
					}
				})
			}
		}, false);

		//拍照 
		function getImage(type) {

			var c = plus.camera.getCamera();
			c.captureImage(function(e) {
				plus.io.resolveLocalFileSystemURL(e, function(entry) {
					var s = entry.toLocalURL() + "?version=" + new Date().getTime();
					if(type == "changeImg") {
						var image = new Image();
						image.src = s;
						image.onload = function() {
							imgData = getBase64Image(image);
							sendImg(s, imgData);
						}
					} else if(type == "question") {
						var image = new Image();
						image.src = s;
						image.onload = function() {
							imgData3 = getBase64Image(image);
							document.getElementById("qusetion-img").src = s;
						}
					}

				}, function(e) {
					console.log("读取拍照文件错误：" + e.message);
				});
			}, function(s) {
				console.log("error" + s);
			}, {
				filename: "_doc/head.png"
			})
		}
		//本地相册选择 
		function galleryImg(type) {

			plus.gallery.pick(function(a) {
				plus.io.resolveLocalFileSystemURL(a, function(entry) {
					plus.io.resolveLocalFileSystemURL("_doc/", function(root) {
						root.getFile("head.png", {}, function(file) {
							//文件已存在 
							file.remove(function() {
								console.log("file remove success");
								entry.copyTo(root, 'head.png', function(e) {
										var e = e.fullPath + "?version=" + new Date().getTime();
										if(type == "changeImg") {
											var image = new Image();
											image.src = e;
											image.onload = function() {
												imgData2 = getBase64Image(image);
												sendImg(e, imgData2);
											}
										} else if(type == "question") {
											var image = new Image();
											image.src = e;
											image.onload = function() {
												imgData4 = getBase64Image(image);
												document.getElementById("qusetion-img").src = e;
											}
										}

									},
									function(e) {
										console.log('copy image fail:' + e.message);
									});
							}, function() {
								console.log("delete image fail:" + e.message);
							});
						}, function() {
							//文件不存在 
							entry.copyTo(root, 'head.png', function(e) {
									var path = e.fullPath + "?version=" + new Date().getTime();

									if(type == "changeImg") {
										var image = new Image();
										image.src = path;
										image.onload = function() {
											imgData2 = getBase64Image(image);
											sendImg(path, imgData2);
										}
									} else if(type == "question") {
										var image = new Image();
										image.src = path;
										image.onload = function() {
											imgData4 = getBase64Image(image);
											document.getElementById("qusetion-img").src = path;
										}
									}

								},
								function(e) {
									console.log('copy image fail:' + e.message);
								});
						});
					}, function(e) {
						console.log("get _www folder fail");
					})
				}, function(e) {
					console.log("读取拍照文件错误：" + e.message);
				});
			}, function(a) {}, {
				filter: "image"
			})
		};

		//将图片压缩转成base64 
		function getBase64Image(img) {
			var canvas = document.createElement("canvas");
			var width = img.width;
			var height = img.height;
			// calculate the width and height, constraining the proportions 
			if(width > height) {
				if(width > 200) {
					height = Math.round(height *= 200 / width);
					width = 200;
				}
			} else {
				if(height > 200) {
					width = Math.round(width *= 200 / height);
					height = 200;
				}
			}
			canvas.width = width; /*设置新的图片的宽度*/
			canvas.height = height; /*设置新的图片的长度*/
			var ctx = canvas.getContext("2d");
			ctx.drawImage(img, 0, 0, width, height); /*绘图*/
			var dataURL = canvas.toDataURL("image/png", 0.8);
			return dataURL.replace("data:image/png;base64,", "");
		}
		//上传图片
		function sendImg(s, imgData) {

			var network = true;
			if(mui.os.plus) {
				mui.plusReady(function() {
					if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
						network = false;
					}
				});
			}
			if(network) {
				console.log('网络正常,正在发送请求...');

				//phoneText.innerHTML = '手机格式符合';
				mui.ajax({
					type: "post",
					url: "http://113.71.26.27:8080/tpl/own/changeImage",
					async: true,
					data: {
						loginName: loginName,
						Data: imgData
					},
					dataType: "json",
					timeout: 10000,
					crossDomain: true,
					success: function(data) {
						console.log('响应成功！');
						console.log(imgData);
						var sure = JSON.stringify(data);
						if(sure == 'true') {

							document.getElementById("head-img").src = s;
							document.getElementById("head-img1").src = s;
							alert("修改成功");
						} else {
							alert('修改失败');
						}
					},
					error: function(xhr, type, errorThrown) {
						plus.nativeUI.toast(errorThrown);
					}
				});

			} else {
				mui.toast("当前网络不给力，请稍后再试...");
			}
		}

		//修改用户资料--姓名
		document.getElementById("X1").addEventListener('tap', function(e) {
			var Set = document.getElementById("G1");
			var logoName=document.getElementById("logoName");
			var MoRen = document.getElementById("G1").innerHTML;
			var network = true;
			var type = "X1";
			var Name = document.getElementById("name");
			var reg=/^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,10}$/;
			e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
			var btnArray = ['确定', '取消'];
			mui.prompt('请输入修改内容：', MoRen, ' ', btnArray, function(e) {
				if(e.index == 0) {
					if(e.value.match(reg)) {
					if(mui.os.plus) {
						mui.plusReady(function() {
							if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
								network = false;
							}
						});
					}
					if(network) {
						console.log('网络正常,正在发送请求...');
						mui.ajax({
							type: "post",
							url: "http://113.71.26.27:8080/tpl/own/changePeople",
							async: true,
							data: {
								loginName: loginName,
								value: e.value,
								type: type
							},
							dataType: "json",
							timeout: 1000,
							crossDomain: true,
							success: function(data) {
								console.log('响应成功！');
								var sure = JSON.stringify(data);
								if(sure == 'true') {
									Set.innerText = e.value;
									Name.innerHTML = "姓名：" + e.value;
									logoName.innerHTML=e.value;
									MoRen = e.value;
									alert("修改成功");

								} else {
									alert("修改失败");
								}
							},
							error: function(xhr, type, errorThrown) {
								plus.nativeUI.toast(errorThrown);
								//alert(errorThrown);
							}
						});
					} else {
						mui.toast("当前网络不给力，请稍后再试...");
					}
				} else {
						alert("姓名格式不对");
					}
				} else {

				}
			})
		});
		//年龄
		document.getElementById("X2").addEventListener('tap', function(e) {
			var Set = document.getElementById("G2");
			var MoRen = document.getElementById("G2").innerHTML;
			var network = true;
			var type = "X2";

			e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
			var btnArray = ['确定', '取消'];
			mui.prompt('请输入修改内容：', MoRen, ' ', btnArray, function(e) {
				if(e.index == 0) {
					var reg = /^(?:[1-9]?\d|100)$/;
					if(e.value.match(reg)) {
						if(mui.os.plus) {
							mui.plusReady(function() {
								if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
									network = false;
								}
							});
						}
						if(network) {
							console.log('网络正常,正在发送请求...');
							mui.ajax({
								type: "post",
								url: "http://113.71.26.27:8080/tpl/own/changePeople",
								async: true,
								data: {
									loginName: loginName,
									value: e.value,
									type: type
								},
								dataType: "json",
								timeout: 1000,
								crossDomain: true,
								success: function(data) {
									console.log('响应成功！');
									var sure = JSON.stringify(data);
									if(sure == 'true') {
										Set.innerText = e.value;

										MoRen = e.value;
										alert("修改成功");

									} else {
										alert("修改失败");
									}
								},
								error: function(xhr, type, errorThrown) {
									plus.nativeUI.toast(errorThrown);
									//alert(errorThrown);
								}
							});
						} else {
							mui.toast("当前网络不给力，请稍后再试...");
						}
					} else {
						alert("年龄输入不在范围");
					}
				} else {

				}
			})
		});
		//性别
		document.getElementById("X3").addEventListener('tap', function(e) {
			var Set = document.getElementById("G3");
			var MoRen = document.getElementById("G3").innerHTML;
			var network = true;
			var type = "X3";

			e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
			var btnArray = ['确定', '取消'];
			mui.prompt('请输入修改内容：男/女', MoRen, ' ', btnArray, function(e) {
				if(e.index == 0) {
					if(e.value == '男' || e.value == '女') {
						if(mui.os.plus) {
							mui.plusReady(function() {
								if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
									network = false;
								}
							});
						}
						if(network) {
							console.log('网络正常,正在发送请求...');
							mui.ajax({
								type: "post",
								url: "http://113.71.26.27:8080/tpl/own/changePeople",
								async: true,
								data: {
									loginName: loginName,
									value: e.value,
									type: type
								},
								dataType: "json",
								timeout: 1000,
								crossDomain: true,
								success: function(data) {
									console.log('响应成功！');
									var sure = JSON.stringify(data);
									if(sure == 'true') {
										Set.innerText = e.value;

										MoRen = e.value;
										alert("修改成功");

									} else {
										alert("修改失败");
									}
								},
								error: function(xhr, type, errorThrown) {
									plus.nativeUI.toast(errorThrown);
									//alert(errorThrown);
								}
							});
						} else {
							mui.toast("当前网络不给力，请稍后再试...");
						}
					} else {
						alert("输入的性别不为男/女");
					}
				} else {

				}
			})
		});
		//qq号
		document.getElementById("X4").addEventListener('tap', function(e) {
			var Set = document.getElementById("G4");
			var MoRen = document.getElementById("G4").innerHTML;
			var network = true;
			var type = "X4";

			e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
			var btnArray = ['确定', '取消'];
			mui.prompt('请输入修改内容：', MoRen, ' ', btnArray, function(e) {
				if(e.index == 0) {
					var reg =/^[1-9][0-9]{4,9}$/;
					if(e.value.match(reg)) {
						if(mui.os.plus) {
							mui.plusReady(function() {
								if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
									network = false;
								}
							});
						}
						if(network) {
							console.log('网络正常,正在发送请求...');
							mui.ajax({
								type: "post",
								url: "http://113.71.26.27:8080/tpl/own/changePeople",
								async: true,
								data: {
									loginName: loginName,
									value: e.value,
									type: type
								},
								dataType: "json",
								timeout: 1000,
								crossDomain: true,
								success: function(data) {
									console.log('响应成功！');
									var sure = JSON.stringify(data);
									if(sure == 'true') {
										Set.innerText = e.value;

										MoRen = e.value;
										alert("修改成功");

									} else {
										alert("修改失败");
									}
								},
								error: function(xhr, type, errorThrown) {
									plus.nativeUI.toast(errorThrown);
									//alert(errorThrown);
								}
							});
						} else {
							mui.toast("当前网络不给力，请稍后再试...");
						}
					} else {
						alert("QQ号格式不符合");
					}
				} else {

				}
			})
		});
		//手机号
		document.getElementById("X5").addEventListener('tap', function(e) {
			var Set = document.getElementById("G5");
			var MoRen = document.getElementById("G5").innerHTML;
			var network = true;
			var type = "X5";
			var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
			e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
			var btnArray = ['确定', '取消'];
			mui.prompt('请输入修改内容：', MoRen, ' ', btnArray, function(e) {
				if(e.index == 0) {
					if(e.value.match(reg)) {
						if(mui.os.plus) {
							mui.plusReady(function() {
								if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
									network = false;
								}
							});
						}
						if(network) {
							console.log('网络正常,正在发送请求...');
							mui.ajax({
								type: "post",
								url: "http://113.71.26.27:8080/tpl/own/changePeople",
								async: true,
								data: {
									loginName: loginName,
									value: e.value,
									type: type
								},
								dataType: "json",
								timeout: 1000,
								crossDomain: true,
								success: function(data) {
									console.log('响应成功！');
									var sure = JSON.stringify(data);
									if(sure == 'true') {
										Set.innerText = e.value;

										MoRen = e.value;
										alert("修改成功");

									} else {
										alert("修改失败");
									}
								},
								error: function(xhr, type, errorThrown) {
									plus.nativeUI.toast(errorThrown);
									//alert(errorThrown);
								}
							});
						} else {
							mui.toast("当前网络不给力，请稍后再试...");
						}
					} else {
						alert("手机号格式不符合！");
					}
				} else {

				}
			})
		});
		//邮箱
		document.getElementById("X6").addEventListener('tap', function(e) {
			var Set = document.getElementById("G6");
			var MoRen = document.getElementById("G6").innerHTML;
			var network = true;
			var type = "X6";
			var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
			e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
			var btnArray = ['确定', '取消'];
			mui.prompt('请输入修改内容：', MoRen, ' ', btnArray, function(e) {
				if(e.index == 0) {
					if(e.value.match(reg)) {
						if(mui.os.plus) {
							mui.plusReady(function() {
								if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
									network = false;
								}
							});
						}
						if(network) {
							console.log('网络正常,正在发送请求...');
							mui.ajax({
								type: "post",
								url: "http://113.71.26.27:8080/tpl/own/changePeople",
								async: true,
								data: {
									loginName: loginName,
									value: e.value,
									type: type
								},
								dataType: "json",
								timeout: 1000,
								crossDomain: true,
								success: function(data) {
									console.log('响应成功！');
									var sure = JSON.stringify(data);
									if(sure == 'true') {
										Set.innerText = e.value;

										MoRen = e.value;
										alert("修改成功");

									} else {
										alert("修改失败");
									}
								},
								error: function(xhr, type, errorThrown) {
									plus.nativeUI.toast(errorThrown);
									//alert(errorThrown);
								}
							});
						} else {
							mui.toast("当前网络不给力，请稍后再试...");
						}
					} else {
						alert("邮箱格式不符合！");
					}
				} else {

				}
			})
		});
		//地址
		document.getElementById("X7").addEventListener('tap', function(e) {
			var Set = document.getElementById("G7");
			var MoRen = document.getElementById("G7").innerHTML;
			var network = true;
			var type = "X7";

			e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
			var btnArray = ['确定', '取消'];
			mui.prompt('请输入修改内容：', MoRen, ' ', btnArray, function(e) {
				if(e.index == 0) {
					if(mui.os.plus) {
						mui.plusReady(function() {
							if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
								network = false;
							}
						});
					}
					if(network) {
						console.log('网络正常,正在发送请求...');
						mui.ajax({
							type: "post",
							url: "http://113.71.26.27:8080/tpl/own/changePeople",
							async: true,
							data: {
								loginName: loginName,
								value: e.value,
								type: type
							},
							dataType: "json",
							timeout: 1000,
							crossDomain: true,
							success: function(data) {
								console.log('响应成功！');
								var sure = JSON.stringify(data);
								if(sure == 'true') {
									Set.innerText = e.value;

									MoRen = e.value;
									alert("修改成功");

								} else {
									alert("修改失败");
								}
							},
							error: function(xhr, type, errorThrown) {
								plus.nativeUI.toast(errorThrown);
								//alert(errorThrown);
							}
						});
					} else {
						mui.toast("当前网络不给力，请稍后再试...");
					}

				} else {

				}
			})
		});
		//问题提交
		//上传图片
		function sendQusetion(s, imgData) {
			var questionText = document.getElementById('questionText');
			var line = document.getElementById('line');
			var startNum = start.toString();
			var reg = /[1-9][0-9]{4,}/;
			var reg2 = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
			if(imgData3 == "") {
				sendImgData = imgData4;

			} else {
				sendImgData = imgData3;

			}
			if(questionText.value != "" && line.value != "" && startNum != "0" ) {
				if(line.value.match(reg)||line.value.match(reg2)) {
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
					console.log('网络正常,正在发送请求...');

					mui.ajax({
						type: "post",
						url: "http://113.71.26.27:8080/tpl/own/sendQusetion",
						async: true,
						data: {
							loginName: loginName,
							massage: questionText.value,
							line: line.value,
							point: start,
							Data: sendImgData
						},
						dataType: "json",
						timeout: 5000,
						crossDomain: true,
						success: function(data) {
							console.log('响应成功！');
							console.log(data);
							var sure = JSON.stringify(data);
							if(sure == 'true') {
								alert("提交成功");
								//plus.webview.currentWebview().g;
								//plus.webview.open('phoneIndex.html','phoneIndex.html');
								//var self = plus.webview.currentWebview();
								mui.back();
							} else {
								alert('提交失败');
							}
						},
						error: function(xhr, type, errorThrown) {
							plus.nativeUI.toast(errorThrown);
						}
					});

				} else {
					mui.toast("当前网络不给力，请稍后再试...");
				}
				}else{
						plus.nativeUI.toast('QQ或者邮箱格式不符合！', {
					verticalAlign: 'center'
				});
				}
			} else {
				plus.nativeUI.toast('输入不能为空！', {
					verticalAlign: 'center'
				});

			}

		}

		///*点击头像触发*/
		document.getElementById('qusetion-img').addEventListener('tap', function() {
			if(mui.os.plus) {
				var a = [{
					title: "拍照"
				}, {
					title: "从手机相册选择"
				}];
				plus.nativeUI.actionSheet({
					title: "选择图片",
					cancel: "取消",
					buttons: a
				}, function(b) { /*actionSheet 按钮点击事件*/
					switch(b.index) {
						case 0:
							break;
						case 1:
							getImage("question"); /*拍照*/
							break;
						case 2:
							galleryImg("question"); /*打开相册*/
							break;
						default:
							break;
					}
				})
			}
		}, false);
		//星星标记
		mui('.icons').on('tap', 'i', function() {
			var index = parseInt(this.getAttribute("data-index"));
			var parent = this.parentNode;
			var children = parent.children;
			if(this.classList.contains("mui-icon-star")) { //点击的那个之前如果由空心的星星变成实心的
				for(var i = 0; i < index; i++) {
					children[i].classList.remove('mui-icon-star'); //star是空心的星星
					children[i].classList.add('mui-icon-star-filled'); //filled是实心的黄色星星
				}
			} else {
				for(var i = index; i < 5; i++) { //点击的那个之后由实心的星星变成空心的
					children[i].classList.add('mui-icon-star')
					children[i].classList.remove('mui-icon-star-filled')
				}
			}
			//打了几颗星呢

			start = index;
		});
		//快速填意见
		document.getElementById('tip1').addEventListener('tap', function() {
			var tipText1 = document.getElementById('tipText1');
			var questionText = document.getElementById('questionText');
			questionText.innerHTML=tipText1.innerHTML;
		}, false);

		
		document.getElementById('tip2').addEventListener('tap', function() {
			var tipText2 = document.getElementById('tipText2');
			var questionText = document.getElementById('questionText');
			questionText.innerHTML=tipText2.innerHTML;
		}, false);
		
		document.getElementById('tip3').addEventListener('tap', function() {
			var tipText3 = document.getElementById('tipText3');
			var questionText = document.getElementById('questionText');
			questionText.innerHTML=tipText3.innerHTML;
		}, false);
		document.getElementById('tip4').addEventListener('tap', function() {
			var tipText4 = document.getElementById('tipText4');
			var questionText = document.getElementById('questionText');
			questionText.innerHTML=tipText4.innerHTML;
		}, false);
		
		
		//分享操作
		var shares = {};
		var tip="";//最新软件版本
		mui.plusReady(function() {
			plus.share.getServices(function(s) {
				if(s && s.length > 0) {
					for(var i = 0; i < s.length; i++) {
						var t = s[i];
						shares[t.id] = t;
					}
				}
			}, function() {
				console.log("获取分享服务列表失败");
			});
		});

		//分享链接点击事件
		document.getElementById("share").addEventListener('tap', function() {
			var ids = [{
					id: "weixin",
					ex: "WXSceneSession"
				}, {
					id: "weixin",
					ex: "WXSceneTimeline"
				}, {
					id: "sinaweibo"
				}, {
					id: "tencentweibo"
				}, {
					id: "qq"
				}],
				bts = [{
					title: "发送给微信好友"
				}, {
					title: "分享到微信朋友圈"
				}, {
					title: "分享到新浪微博"
				}, {
					title: "分享到腾讯微博"
				}, {
					title: "分享到QQ"
				}];
			plus.nativeUI.actionSheet({
				cancel: "取消",
				buttons: bts
			}, function(e) {
				var i = e.index;
				if(i > 0) {
					var s_id = ids[i - 1].id;
					var share = shares[s_id];
					if(share) {
						if(share.authenticated) {
							shareMessage(share, ids[i - 1].ex);
						} else {
							share.authorize(function() {
								shareMessage(share, ids[i - 1].ex);
							}, function(e) {
								console.log("认证授权失败：" + e.code + " - " + e.message);
							});
						}
					} else {
						mui.toast("无法获取分享服务，请检查manifest.json中分享插件参数配置，并重新打包")
					}
				}
			});
		});

		function shareMessage(share, ex) {
			var msg = {
				extra: {
					scene: ex
				}
			};
			 var url= "http://113.71.26.27:8080/tpl/own/getUpdate";
			mui.ajax(url,{
                data:{
                },
                dataType:'text',
                type:'post',
                timeout:10000,
                async: true,
                crossDomain: true,
                success:function(data){
                	console.log('响应成功！');
                    //console.log(data);
					var sure = data;
					
					msg.href = "http://113.71.26.27:8080/tpl/public/update/"+sure;
					msg.title = "微架构";
					msg.content = "我正在使用微架构，它能帮我快速搭建企业组织的框架";
					if(~share.id.indexOf('weibo')) {
						msg.content += "；体验地址：http://113.71.26.27:8080/tpl/public/update/"+sure;
					}
					msg.thumbs = ["_www/images/logo.png"];
					share.send(msg, function() {
						console.log("分享到\"" + share.description + "\"成功！ ");
					}, function(e) {
						console.log("分享到\"" + share.description + "\"失败: " + e.code + " - " + e.message);
					});
					
                    
                },
                error: function(xhr, type, errerThrown) {
                     plus.nativeUI.toast(errerThrown);
                }
            });
			
		}

		//客服电话
		document.getElementById("tel").addEventListener('tap', function() {
			if(mui.os.plus) {
				plus.device.dial("13570406018");
			} else {
				
				location.href = 'tel:13570406018';
			}

		});
		//检查更新
		var ver="";
		mui('.mui-table-view-cell').on('click', '#update', function() {
        plus.runtime.getProperty(plus.runtime.appid, function(inf) {
            ver = inf.version;
            console.log("当前应用版本：" + ver);
            var url= "http://113.71.26.27:8080/tpl/own/update";
            var client;
            if(mui.os.ios) {client='ios';}
            else{client='android';}
			var network = true;
					if(mui.os.plus) {
						mui.plusReady(function() {
							if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
								network = false;
							}
						});
					}
					if(network) {
						console.log('网络正常,正在发送请求...');
            mui.ajax(url,{
                data:{
                    version: ver,
                    client:client
                },
                dataType:'text',
                type:'post',
                timeout:10000,
                async: true,
                crossDomain: true,
                success:function(data){
                	console.log('响应成功！');
                    //console.log(data);
					var sure = data;
					updateFile=sure;
					var apkUrl="http://113.71.26.27:8080/tpl/public/update/" +sure;
                    if(sure != 'false'){
                        var btnArray = ['是', '否'];
                        mui.confirm('是否更新', '发现最新版本', btnArray, function(z) {
                            if (z.index == 0) {
                                // 创建下载任务  
								console.log(apkUrl);
                               plus.runtime.openURL( apkUrl,"","");
                             }else {
                                
                                return;
                            }
                        });
                    }
                    else{
                        plus.nativeUI.toast("微架构已是最新版本");
                    }
                },
                error: function(xhr, type, errerThrown) {
                     plus.nativeUI.toast(errerThrown);
                }
            });
	}else {
		mui.toast("当前网络不给力，请稍后再试...");
		}
        });
    });
	</script>

	<script>
		mui.init();
		mui.plusReady(
			function() {
				document.getElementById("out").addEventListener('tap', function() {
					var btnArray = ['否', '是'];
					mui.confirm('是否退出，确认？', '微架构', btnArray, function(e) {
						if(e.index == 1) {
							
							plus.webview.currentWebview().hide();
							plus.webview.open('phoneLogin.html', 'phoneLogin.html');
							
							
											
						localStorage.setItem("ifLogin","false");//登陆状态
						changeState("true");//改变登陆状态
						
							
						} else {

						}
					})

				});
			}
		);
		
		
		
		
		//改变登陆状态
			function changeState(state){
				console.log('改变登陆状态');
				mui.ajax({
							type: "post",
							url: "http://113.71.26.27:8080/tpl/phone/changeState",
							async: true,
							data: {
								name: loginName,
								state: state
							},
							dataType: "json",
							timeout: 2000,
							crossDomain: true,
							success: function(data) {
								console.log('响应成功！');
								
								
							},
							error: function(xhr, type, errorThrown) {
								plus.nativeUI.toast(errorThrown);
							}
						});
				
			}
	</script>

</html>